package com.seecen.webproject.dao;

import com.seecen.webproject.entity.User;

import java.util.List;

public class UserDao extends BaseDao {
    public User queryByUsername(String username) {
        List<User> users = query(User.class, "select * from USER where username=?", username);
        if(users != null && users.size() > 0) return users.get(0);
        return null;
    }

    public int save(User user) {
        // 插入数据
        String insertSQL = "INSERT INTO USER (USERNAME, PASSWORD, CREATE_TIME) VALUES (?, ?, current_timestamp())";
        return doUpdate(insertSQL, user.getUsername(), user.getPassword());
    }
}
